package timing.ukulele.user.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicConfig {

    // 微信推送
    public static final String WX_MP_CHANNEL = "wx_mp_channel";
    public static final String WX_MP_ROUTING = "wx_mp.routing";

    // 发邮件
    public static final String EMAIL_CHANNEL = "email_channel";
    public static final String EMAIL_ROUTING = "email.routing";

    // 修改密码
    public static final String PASSWORD_CHANNEL = "passorod_channel";
    public static final String PASSWORD_ROUTING = "password.routing";


    @Bean
    public Queue wxMpCropQueue() {
        return new Queue(WX_MP_ROUTING);
    }

    @Bean
    public TopicExchange wxMpExchange() {
        return new TopicExchange(WX_MP_CHANNEL);
    }

    @Bean
    public Binding bindWxMpExchange(Queue wxMpCropQueue, TopicExchange wxMpExchange) {
        return BindingBuilder.bind(wxMpCropQueue).to(wxMpExchange).with(WX_MP_ROUTING);
    }

    @Bean
    public Queue emailQueue() {
        return new Queue(EMAIL_ROUTING);
    }

    @Bean
    public TopicExchange emailExchange() {
        return new TopicExchange(EMAIL_CHANNEL);
    }

    @Bean
    public Binding bindEmailExchange(Queue emailQueue, TopicExchange emailExchange) {
        return BindingBuilder.bind(emailQueue).to(emailExchange).with(EMAIL_ROUTING);
    }

    @Bean
    public Queue passwordQueue() {
        return new Queue(PASSWORD_ROUTING);
    }

    @Bean
    public TopicExchange passwordExchange() {
        return new TopicExchange(PASSWORD_CHANNEL);
    }

    @Bean
    public Binding bindPasswordExchange(Queue passwordQueue, TopicExchange passwordExchange) {
        return BindingBuilder.bind(passwordQueue).to(passwordExchange).with(PASSWORD_ROUTING);
    }
}
